export function safeRemoveFromFather(child: egret.DisplayObject): void{
	if (child && child.parent) {
		child.parent.removeChild(child);
	}
}


export function fulllAlign(obj: eui.UIComponent): void{
	obj.left = 0;
	obj.right = 0;
	obj.top = 0;
	obj.bottom = 0;
}

export function allCenter(obj: eui.UIComponent): void{
	obj.verticalCenter = 0;
	obj.horizontalCenter = 0;
}


// 祖先
function isOldParent(chlid: egret.DisplayObject, parent: egret.DisplayObject): boolean {
	let p = chlid.parent;
	while (p) {
		if (p === parent) {
			return true;
		}
		p = p.parent;
	}
	return false;
}

export function isSelfOrParent(
	chlid: egret.DisplayObject,
	parent: egret.DisplayObject,
): boolean {
	return chlid === parent || isOldParent(chlid, parent);
}
